package com.acwing.partition34;

import java.io.*;

/**
 * @author rkc
 * @date 2022/7/19 9:44
 */
public class AC3381手机键盘 {

    private static final int[] numbers = {2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9};

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        while (true) {
            String s = reader.readLine();
            if (s == null || s.isEmpty()) break;
            int ans = 0, last = -1;
            for (int i = 0; i < s.length(); i++) {
                int t = s.charAt(i) - 'a';
                for (int j = t; j >= 0; j--) {
                    if (numbers[j] == numbers[t]) ans++;
                    else break;
                }
                if (last != -1 && numbers[t] == numbers[last]) ans += 2;
                last = t;
            }
            writer.write(ans + "\n");
        }
        writer.flush();
    }
}
